// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    tabs: ['游戏','直播','娱乐','新闻'],
    activeIndex: 1,
    allData: [],
    activeKey: 0,
    processWidth: 0,
    triggered: false,
    show: false
  },

  onLoad() {
    wx.request({
      url: 'http://localhost:3000/list',
      success:(res) => {
        this.setData({
          allData: res.data
        })
        console.log(res.data)
      }
    })
  },
  changeActive(e) {
    const {index} = e.currentTarget.dataset;
    this.setData({
      activeIndex: index
    })
  },
  onSlide(e) {
    this.setData({
      activeIndex: e.detail.current
    })
  },

  changeListActive(e) {
    this.setData({
      activeKey: e.detail
    })
  },
  refresherpulling(e) {
    const width = 750 * e.detail.dy/100;
    this.setData({
      processWidth: width,
      triggered: true
    })
  },
  refresh() {
    setTimeout(() => {
      this.setData({
        triggered: false
      })
    }, 1000)
    
  },
  onClose() {
    this.setData({
      show: false
    })
  },
  onOpen() {
    this.setData({
      show: true
    })
  }
})
